/**
 * https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/description/
 * @param {number[]} prices
 * @return {number}
 */

 var maxProfit = function(prices) {
  let last = prices[0];
  let maxP = 0;
  for (let i = 1; i < prices.length; i++) {
      if (prices[i] > last) {
          maxP += (prices[i] - last);
      }
      last = prices[i];
  }
  return maxP
};